package com.mep.auth.controller;

import com.mep.auth.feign.IFeignSysConfigApi;
import com.mep.auth.model.SysConfig;
import com.mep.auth.service.SysConfigService;
import com.mep.common.http.HttpResult;
import com.mep.common.page.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 系统配置控制器
 * @author lyl
 * @date Jan 13, 2019
 */

@Api(value="008-config的controller",tags="008-config的controller")
@RestController
@RequestMapping("config")
public class SysConfigController implements IFeignSysConfigApi {

	@Autowired
	private SysConfigService sysConfigService;

	@Override
	@ApiOperation(value="01.保存config",notes="问题点:保存config")
	@ApiOperationSupport(order = 1, author = "lyl")
	@PostMapping(value="/save")
	public HttpResult save(@RequestBody SysConfig record) {
		return HttpResult.ok(sysConfigService.save(record));
	}

	@Override
	@ApiOperation(value="02.删除config",notes="问题点:删除config")
	@ApiOperationSupport(order = 2, author = "lyl")
	@PostMapping(value="/delete")
	public HttpResult delete(@RequestBody List<SysConfig> records) {
		return HttpResult.ok(sysConfigService.delete(records));
	}

	@Override
	@ApiOperation(value="03.查询config分页数据",notes="问题点:查询config分页数据")
	@ApiOperationSupport(order = 3, author = "lyl")
	@PostMapping(value="/findPage")
	public HttpResult findPage(@RequestBody PageRequest pageRequest) {
		return HttpResult.ok(sysConfigService.findPage(pageRequest));
	}

	@Override
	@ApiOperation(value="04.根据label查询config信息",notes="问题点:根据label查询config信息")
	@ApiOperationSupport(order = 4, author = "lyl")
	@PostMapping(value="/findByLable")
	public HttpResult findByLable(@RequestParam String lable) {
		return HttpResult.ok(sysConfigService.findByLable(lable));
	}
}
